package controller;

import java.util.Collection;
import java.util.HashSet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonProcessingException;

import command.Command;

import model.ApplicationModel;
import model.User;
import sma.AgentController;

public class MultiDeviceController {

	private static final Logger log = LoggerFactory
			.getLogger(MultiDeviceController.class);

	private final ApplicationController applicationController;
	private final AgentController agentController;

	public MultiDeviceController(ApplicationController applicationController,
			ApplicationModel model) {
		this.applicationController = applicationController;
		this.agentController = new AgentController(model);
		init();
	}

	private void init() {
		agentController.initAgent();
	}

	public void dispatch(Command command) {
		// temp method content, to be changed once verified
		try {
			String content = command.getContentAsString();
			log.debug("dispatching : {}", content);
			//agent.controller....
		} catch (JsonProcessingException e) {
			log.error("command.getContentAsString() FAILED");
			e.printStackTrace();
		}

	}

	public void runRemoteCommand(Command command) {
		applicationController.runRemoteCommand(command);
	}

	public Collection<User> getRemoteActiveUsersOnProject(Long projectId) {
		return new HashSet<User>(0);
	}

}
